import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getTokentime() {
  return Cookies.get('token-time')
}

export function setTokentime(time) {
  return Cookies.set('token-time', time)
}

export function removeTokentime() {
  return Cookies.remove('token-time')
}


export function getUserId() {
  return Cookies.get('UserId')
}

export function setUserId(UserId) {
  return Cookies.set('UserId', UserId)
}

export function removeUserId() {
  return Cookies.remove('UserId')
}
export function tokenStartTime() {
  return Cookies.set('tokenStartTime', new Date().getTime())
}
export function removeStartTime() {
  return Cookies.remove('tokenStartTime')
}
export function settokenTime() {
  return Cookies.get('tokenStartTime')
}
export function getUserInfo() {
  const cookie = Cookies.get('UserInfo')
  return cookie ? JSON.parse(cookie) : undefined
}

export function setUserInfo(UserInfos) {
  return Cookies.set('UserInfo', JSON.stringify(UserInfos))
}
export function removeUserInfo() {
  return Cookies.remove('UserInfo')
}


const labHeader = 'Admin-labHeader'
export function getHeader() {
  return Cookies.get(labHeader)
}

export function setHeader(list) {
  return Cookies.set(labHeader, list)
}

export function removeHeader() {
  return Cookies.remove(labHeader)
}


export function getMenuList() {
  const cookieValue = localStorage.getItem('MenuList')
  return cookieValue ? JSON.parse(cookieValue) : undefined
}

export function setMenuList(MenuList) {
  return localStorage.setItem('MenuList', JSON.stringify(MenuList))
}
export function removeMenuList() {
  return localStorage.removeItem('MenuList')
}